//
//  YGWebViewController.m
//  AllYoga
//
//  Created by 郭静芬 on 2016/9/28.
//  Copyright © 2016年 郭静芬. All rights reserved.
//

#import "GJFWebViewController.h"
#import <WebKit/WebKit.h>
@interface GJFWebViewController () <UIWebViewDelegate, WKUIDelegate, WKNavigationDelegate,UMSocialShareMenuViewDelegate>
{
    NSString *_url;
}
@property (nonatomic, strong) UIWebView *webViewUI;
@property (nonatomic, strong) WKWebView *webViewWK;
@end

@implementation GJFWebViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    if (![self.navigationItem.title isEqualToString:@"关于我们"]) {
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon-分享"] style:UIBarButtonItemStyleDone target:self action:@selector(shareAction)];
    }
}
- (void)shareAction {
    [GJFSingleTool shareToViewController:self title:@"幻紫琉晶" content:self.navigationItem.title image:nil url:_url];
}

- (void)createInfoWithTitle:(NSString *)title url:(NSString *)url options:(id)options {
    self.navigationItem.title = title;
    _url = url;
    if (isiOS8) {
        if (options) {
            [self.webViewWK loadHTMLString:options baseURL:nil];
        }
        else {
            [self.webViewWK loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
        }
    }
    else {
        if (options) {
            [self.webViewUI loadHTMLString:options baseURL:nil];
        }
        else {
            [self.webViewUI loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
        }
    }
}

- (UIWebView *)webViewUI {
    if (!_webViewUI) {
        _webViewUI = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64)];
        _webViewUI.delegate = self;
        [self.view addSubview:_webViewUI];
    }
    return _webViewUI;
}

- (WKWebView *)webViewWK {
    if (!_webViewWK) {
        _webViewWK = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64)];
        _webViewWK.UIDelegate = self;
        _webViewWK.navigationDelegate = self;
        [self.view addSubview:_webViewWK];
    }
    return _webViewWK;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
